﻿using Microsoft.EntityFrameworkCore;
using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
using Prism.Services.Dialogs;
using Prism.Unity;
using System.Configuration;
using System.Data;
using System.Windows;
using XH.DataUpload.Client.Base;
using XH.DataUpload.Client.Global;
using XH.DataUpload.Client.ViewModels;
using XH.DataUpload.Client.Views;
using XH.DataUpload.ORM;
using XH.DataUpload.Service;

namespace XH.DataUpload.Client
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainView>();
        }
        protected override void InitializeShell(Window shell)
        {
            base.InitializeShell(shell);
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterDialog<LoginView>();
            containerRegistry.RegisterDialogWindow<DialogWindowEx>();

            // 注册需要的实体
            containerRegistry.RegisterSingleton<DbContext, XHDbContext>();
            containerRegistry.Register<IUserService, UserService>();
            containerRegistry.RegisterForNavigation<UserMainView, UserMainViewModel>();
            containerRegistry.RegisterForNavigation<UserConfigView, UserConfigViewModel>();
            containerRegistry.RegisterForNavigation<UserEngineeringView, UserEngineeringViewModel>();

            // 注册事件聚合器
            Messenger.Defualt = Container.Resolve<IEventAggregator>();

        }
    }

}
